package com.goldfish666.houghrecognition.util;

import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public class Constant {

    public static void initialDictionary(String input) {
        if (!dictionaryInitialized) {
            String pictureDictionary = input.endsWith("\\") ? input : input + "\\";
            pictureDictionary = pictureDictionary.endsWith("picture\\") ? pictureDictionary : pictureDictionary + "picture\\";
            sourceDictionary = pictureDictionary + "source\\";
            skeletonDictionary = pictureDictionary + "model\\";
            captchaDictionary = pictureDictionary + "captcha\\";
            resultDictionary = pictureDictionary + "result\\";
            dictionaryInitialized = true;
        }
    }

    public static void initialTargetSet(Set<String> set) {
        if (!targetSetInitialized) {
            targetSet = set;
            targetSetInitialized = true;
        }
    }

    public static void initialTargetNameMap(Map<String, String> map) {
        if (!targetNameMapInitialized) {
            targetNameMap = map;
            targetNameMapInitialized = true;
        }
    }

    public static void initialCaptchaNameSet(Set<String> set) {
        if (!captchaNameSetInitialized) {
            captchaNameSet = set;
            captchaNameSetInitialized = true;
        }

    }

    private static boolean dictionaryInitialized = false;

    private static boolean targetSetInitialized = false;

    private static boolean targetNameMapInitialized = false;

    private static boolean captchaNameSetInitialized = false;

    // 基本字符的目录("D:\\picture\\re\\source\\")
    private static String sourceDictionary = "";

    public static String getSourceDictionary() {
        return sourceDictionary;
    }

    // 待识别字符的名称和对应的文件名称(0,0.jpg)
    private static Map<String, String> targetNameMap = new LinkedHashMap<>();

    public static Map<String, String> getTargetNameMap() {
        return targetNameMap;
    }

    // 基本字符集合(0123jkl)
    private static Set<String> targetSet = new HashSet<>();

    public static Set<String> getTargetSet() {
        return targetSet;
    }

    // 基本字符骨架图目录
    private static String skeletonDictionary = "";

    public static String getSkeletonDictionary() {
        return skeletonDictionary;
    }

    // 待识别验证码目录
    private static String captchaDictionary = "";

    public static String getCaptchaDictionary() {
        return captchaDictionary;
    }

    // 待识别验证码文件名称集合(captcha0.jpg)
    private static Set<String> captchaNameSet = new HashSet<>();

    public static Set<String> getCaptchaNameSet() {
        return captchaNameSet;
    }

    // 识别结果目录
    private static String resultDictionary = "";

    public static String getResultDictionary() {
        return resultDictionary;
    }
}
